package com.ruoyi.system.controller;

import com.ruoyi.system.domain.Camera;
import com.ruoyi.system.mapper.CameraMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/camera")
public class CameraController {
    @Resource
    CameraMapper cameraMapper;

    //获取含经纬度的摄像头信息
    //将数据中deploy_location拆分为经纬度
    @GetMapping
    public List<Camera> getDevice(){
        List<Camera> cameras = cameraMapper.findAll();
        for(Camera camera:cameras){
            String deploy_location = camera.getDeploy_location();
            String[] strings = deploy_location.split(",");
            double lon = Double.parseDouble(strings[0]);//经度
            double lat = Double.parseDouble(strings[1]);//纬度
            camera.setLon(lon);
            camera.setLat(lat);
            System.out.println(lat);
        }
        return cameras;
    }
}
